<?php

//include_once '../../data/config.php';
//include_once '../../data/DBConn.php';

	require_once ($_SERVER['DOCUMENT_ROOT']."/Auditing/data/config.php");
	require_once ($_SERVER['DOCUMENT_ROOT']."/Auditing/data/DBConn.php");
	
	
 Class RetrieveComboData{
 	
 	var $query;
 	var $conn;
	var $dbConn;
	var $sqlString;
	var $param;
 	
function RetrieveComboData(){
		
	  
}

 function getData($sqlString,$param) {
		
		
  		$result = mysql_query($sqlString);
		
          $html="";   
          
		 if (!$result) {
		    die	('Invalid query: ' . mysql_error());
		}    
		
      while ($row = mysql_fetch_array($result)) {
      		
      		if($param==$row[0]){
      			$html .= "<option selected value='" . $row[0] . "'>". $row[1] . "</option>";	
      		}else {
      			$html .= "<option value='" . $row[0] . "'>". $row[1] . "</option>";      			
      		}
         }

         mysql_free_result($result);
       	 return $html;

    }
    
    function getTableNames(){
    	
    	$strQuery="show tables";
		$result = mysql_query($strQuery);
		$i=0;
		$input="";
		
		$arr;
		
		while ($row = mysql_fetch_array($result)) {
			
			$arr[$i]=$row[0];
			$i++;			
		}
		
		 return $arr;
    	
    }
    
    function getFieldNames($tblName) {

    	$option="";
 		$y=0;
    	foreach($tblName as $tb_name){
			$sqlString = "show columns from ";
    		$sqlString = $sqlString.$tb_name;
    		$result = mysql_query($sqlString);
			
		//	$option .= "<option value='".$tb_name.".*'>".$tb_name.".*</option>";
			if($y!=0){
				$option .=	",";
			}
			$option .=	$tb_name.".*";
				
			$x = 0;
			while ($row = mysql_fetch_array($result)) {
			 
			//	$option .= "<option value='" .$tb_name. ".".$row[0] . "'>". $tb_name.".".$row[0] . "</option>";
				$option .=",";
				$option .= $tb_name.".".$row[0];
				$x++;
			}
			$y++;
		
    	}
    	return $option;
    	    	
    }
 }
 
 

?>